bindings: Avoid iterating array if it is never set
authorDaniel Boles <dboles@src.gnome.org>
Tue, 1 Aug 2017 19:41:23 +0000 (20:41 +0100)
committerDaniel Boles <dboles@src.gnome.org>
Tue, 1 Aug 2017 19:45:07 +0000 (20:45 +0100)
If query.return_type is not one we want, binding_compose_params() is
not called, and so params remains a NULL pointer. However, the code was
then unconditionally iterating it regardless. Don't if it is still NULL.

CID 1452218 (#1 of 1): Explicit null dereferenced (FORWARD_NULL)
15. var_deref_op: Dereferencing null pointer params.

gtk/gtkbindings.c

index 57cddec37f7a0c9fd27ce894cc24e44229ac6cd9..d8084c1c800a40769f0f7ad29b28653ebf8740f9 100644 (file)
@@ -654,9 +654,13 @@ gtk_binding_entry_activate (GtkBindingEntry *entry,
       else
         handled = TRUE;
 
-      for (i = 0; i < query.n_params + 1; i++)
-        g_value_unset (&params[i]);
-      g_free (params);
+      if (params != NULL)
+        {
+          for (i = 0; i < query.n_params + 1; i++)
+            g_value_unset (&params[i]);
+
+          g_free (params);
+        }
 
       if (entry->destroyed)
         break;